package pres.man.interview.simple;

/**
 * StringBuilder、StringBuffer效率差距
 *
 * @Author MAN
 * @Date 2021-01-11-16:57
 */
public class BuilderBuffer {

    public static void main(String[] args) {
        long start = System.currentTimeMillis();

        StringBuffer buffer = new StringBuffer();
        for (int i = 0; i < 10000000; i++) {
            buffer.append(i);
        }

        long terminate = System.currentTimeMillis();

        System.out.println("时间花费 : " + (terminate - start) + "毫秒");

        start = System.currentTimeMillis();

        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < 10000000; i++) {
            builder.append(i);
        }

        terminate = System.currentTimeMillis();

        System.out.println("时间花费 : " + (terminate - start) + "毫秒");
    }



}
